package com.lh.blogArticle.service.Impl;

import com.lh.blogArticle.entity.StudyNotesEntity;
import com.lh.blogArticle.entity.TechnicalArticleEntity;
import com.lh.blogArticle.mapper.TechnicalArticleMapper;
import com.lh.blogArticle.service.TechnicalArticleService;
import com.lh.blogCommon.util.PageUtils;
import com.lh.blogCommon.util.Query;
import org.springframework.stereotype.Service;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.util.StringUtils;


@Service("technicalArticleService")
public class TechnicalArticleServiceImpl extends ServiceImpl<TechnicalArticleMapper, TechnicalArticleEntity> implements TechnicalArticleService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        QueryWrapper<TechnicalArticleEntity> queryWrapper = new QueryWrapper<>();

        String key = (String) params.get("key");
        System.out.println(params);
        if(!StringUtils.isEmpty(key)){
            queryWrapper.eq("article_id",key).or()
                    .eq("skills_id",key).or()
                    .eq("article_title", key).or()
                    .eq("article_content", key).or()
                    .eq("creation_time", key).or()
                    .eq("modification_time", key);

        }
        queryWrapper.orderByDesc("article_id");

        IPage<TechnicalArticleEntity> page = this.page(
                new Query<TechnicalArticleEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}